<template>
  <el-dialog class="full-screen" :model-value="visible" top="0" :width="width"  :close-on-click-modal="false" :title="title" :show-close="false" :fullscreen="screenFlag"
    destroy-on-close :before-close="onClose" :draggable="false" append-to-body>

    <template #header>
      <div class="header-container">
        <div class="container-title">
          {{ title }}
        </div>
        <div class="container-close">
          <el-button @click.stop="onClose" size="small">关闭保存</el-button>
        </div>
      </div>
    </template>
    <!-- 怎么设计 我感觉还是有地儿复杂 没得思绪来设计这个 1 弹框 2 布局 3 具体的懂 4 关闭 5 清空数据 -->
    <div class="container">
      <slot name="content" />
    </div>
    <template #footer v-if="showFooter">
      <span class="dialog-footer">
        <el-button @click="onClose">取消</el-button>
        <el-button type="primary" @click="onConfirm">确定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang='ts'>
import { reactive, ref } from 'vue'
const props = defineProps({
  title: {//弹框标题
    type: String,
    default: '标题'
  },
  visible: { //控制弹框的展示和影藏
    type: Boolean,
    default: false
  },
  showFooter: {
    type: Boolean,
    default: true
  },
  width: {
    type: Number,
    default: 500
  },
  screenFlag:{
    type:Boolean,
    default:true
  }
})
const emit = defineEmits(['onClose', 'onConfirm'])
const onClose = () => {
  emit('onClose')
}
const onConfirm = () => {
  emit('onConfirm')
}
</script>
<style lang="scss" scoped>
.container {
  overflow-x: initial;
  overflow-y: auto;
}

.el-dialog {
  border-top-left-radius: 7px !important;
  border-top-right-radius: 7px !important;
  margin: 0 auto !important;
  .el-dialog__header {
    height: 24px;

    .el-dialog__headerbtn {
      top: 0px;
    }

    border-top-left-radius: 7px !important;
    border-top-right-radius: 7px !important;
    background-color: #1890ff !important;
    margin-right: 0;

    .el-dialog__title {
      color: #fff;
      font-size: 16px;
      font-weight: 600;
    }

    .header-container {
      display: flex;
      justify-content: space-between;
    }

    .el-dialog__close {
      color: #fff;
    }
  }

  // .el-dialog__body {
  //   padding: 10px;
  // }
  .el-dialog__body {
    height: calc(100% - 54px);
    width: 100%;
    padding: 0;

    .container {
      height: 100%;
      width: 100%;
    }
  }

  .el-dialog__footer {
    border-top: 1px solid #e8eaec !important;
    padding: 10px;
    display: flex;
    justify-content: center;
  }
}</style>